package com.douqu.game.auth.web.controller;

import com.douqu.game.auth.service.GMService;
import com.douqu.game.core.database.model.GMModel;
import com.douqu.game.core.util.LogUtils;
import com.douqu.game.core.web.response.BaseResponseDto;
import com.douqu.game.core.web.response.SuccessResponseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-09-15 10:52
 */
@RestController
public class GMController {

    @Autowired
    private GMService gmService;

    @RequestMapping(value = "/gm/list")
    public BaseResponseDto list()
    {
        return new SuccessResponseDto(gmService.findList());
    }


    @RequestMapping(value = "/gm/update")
    public BaseResponseDto update(@RequestBody GMModel gmModel) throws IOException
    {
        LogUtils.info("gm update request -> " + gmModel);
        return gmService.update(gmModel);
    }


    @RequestMapping(value = "/gm/login")
    public BaseResponseDto queryByName(String username, String password)
    {
        return gmService.login(username, password);
    }

}
